package org.jmc.refmanager.domain.dao;

import java.io.Serializable;
import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.Query;

import org.jmc.refmanager.domain.dao.exception.TechnicalException;
import org.springframework.orm.jpa.JpaOperations;

public interface GenericDao<E, PK extends Serializable> extends JpaOperations {

	public List<E> findAll() throws TechnicalException;

	public E find(PK pPK) throws TechnicalException;

	public E save(E pEntity) throws TechnicalException;

	public void remove(PK pPK) throws TechnicalException;

	public boolean exists(PK pPK) throws TechnicalException;

	public EntityManager getEntityManager();
	
	public List<E> findAllAndPaging(QueryParam<E> queryParam);
	
	public Integer countAll();

	// Ces deux requetes sont specifiques e Hibernate comme moteur de persistence
	public List<E> findAndPaging(QueryParam<E> queryParam);
	public Integer count(QueryParam<E> queryParam);

	public List<E> findAndPaging(QueryParam<E> queryParam, Query query);

	public Integer count(Query query);
	
	public List<E> findAndPaging(QueryParam<E> queryParam, Query query, Object... params);

	public Integer count(Query query, Object... params);

	public Query createQuery(String jpql);
	
	public Query createNamedQuery(String queryName);
}
